package com.airbnb.mvrx.sample.features.clickread.views

import android.content.Context
import android.widget.LinearLayout
import android.widget.TextView
import com.airbnb.epoxy.ModelProp
import com.airbnb.epoxy.ModelView
import com.airbnb.mvrx.sample.Utils
import com.example.mvrxstudy.R
import com.facebook.drawee.view.SimpleDraweeView

@ModelView(autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT)
class CRThumbItem @JvmOverloads constructor(context: Context) : LinearLayout(context) {

    private val mImage: SimpleDraweeView
    private val mPage: TextView by lazy { findViewById<TextView>(R.id.tv_page) }

    init {
        orientation = LinearLayout.HORIZONTAL
        inflate(context, R.layout.item_thumb_cr, this)
        mImage = findViewById(R.id.iv_image)
    }

    @ModelProp
    fun setImage(thumb: String) {
        mImage.setImageURI(thumb)
    }

    @ModelProp
    fun setPosition(position: Int) {
        mPage.text = Utils.format("%d", position + 1)
    }

}